package com.zxj.camerapreview;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = MainActivity.class.getName() ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        checkPermission();
    }

    private void checkPermission(){
        if(ContextCompat.checkSelfPermission(this,
                Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
        }else{
            Log.d(TAG, "HAS PERMISSION");
        }
    }

    public void onCameraSurfaceViewShowClick(View view) {
        startActivity(new Intent(this,CameraSurfaceViewShowActivity.class));
    }

    public void onCameraTextureViewShowClick(View view) {
        startActivity(new Intent(this,CameraTextureViewShowActivity.class));
    }

    public void onCameraGlSurfaceShowClick(View view) {
        startActivity(new Intent(this,CameraGlSurfaceShowActivity.class));
    }

    public void onMyTextureViewClick(View view) {
        startActivity(new Intent(this,MyTextureViewActivity.class));
    }

    public void onOneOpenGlClick(View view) {
        startActivity(new Intent(this,OneOpenGlActivity.class));
    }

    public void onCustomGlViewClick(View view) {
        startActivity(new Intent(this,CustomGLViewActivity.class));
    }

    public void onCameraHelperShowClick(View view) {
        startActivity(new Intent(this,CameraHelperActivity.class));
    }
}